<template>
  <div>
    <el-row style="margin-bottom:20px;display:flex;justify-content:flex-start">
      <el-select placeholder="请选择培训分类" style="width:20%" v-model="classify" clearable>
        <el-option
          v-for="item in classifyArr"
          :key="item.value"
          :label="item.hash.code_name"
          :value="item.hash.code_id"
        ></el-option>
      </el-select>
      <el-date-picker
        clearable
        v-model="plandate2"
        type="daterange"
        style="margin:0 10px;"
        rangeSeparator="至"
        startPlaceholder="培训开始日期"
        endPlaceholder="培训结束日期"
        valueFormat="yyyy-MM-dd"
      ></el-date-picker>
      <el-button size="mini" type="primary" @click="getplanyearlist">搜索</el-button>
    </el-row>
    <planyeartable :tableData="planyeartable" :pagobj.sync="pagobj" v-if="isworktable3" :ischeck="false"></planyeartable>
  </div>
</template>

<script>
import planyeartable from '~/components/person/workplanyear/planyeartable.vue';

export default {
  data() {
    return {
      ts: this.newStore(),
      isworktable3: true,
      yearData: {
        cols: [],
        hash: {
          username: '',
          tcontent: '',
          ttypename: '',
          duixiang: '',
          starttime: '',
          pid: '',
          id: '',
        },
      },
      pagesize: 0,
      currentPage: 0,
      pagobj: {
        currentPage3: 1,
        pagesize: 100,
        total: 10,
      },
      planyeartable: [],
      classifyArr: [],
      classify: '',
      plandate2: ['', ''],
    };
  },
  created() {
    this.getcodeData('0207', '02', 'classifyArr');
    this.getplanyearlist();
  },
  components: {
    // searchperson,
    planyeartable,
  },
  methods: {
    // 公共方法获取代码项
    getcodeData(supid, codetype, arrname) {
      const req = {
        handle: '67A5B6FEF17D97DECF116BDF95B95C0B167942DD3F1604F9',
        supid,
        codetype,
      };
      this.spost(this.ts, '/mainservlet', req).then((ts) => {
        this[arrname] = ts.d.data.operation1;
      });
    },
    // 获取列表
    getplanyearlist() {
      // console.log("2222");
      if (this.plandate2 == null) {
        this.plandate2 = [];
      }
      const req = {
        handle:
          '33224548EFC2E94F5D1CB0CAB6CFDFF2756AF0B87ABE74A444B455B1B2775577',
        classify: this.classify,
        pre_begintime_begin: this.plandate2[0],
        pre_endtime_end: this.plandate2[1],
        start: (this.pagobj.currentPage3 - 1) * this.pagobj.pagesize,
        limit: this.pagobj.pagesize,
      };
      this.spost(this.ts, '/mainservlet', req).then((ts) => {
        this.planyeartable = ts.d.data.operation1;
        this.isworktable3 = false;
        this.$nextTick(() => {
          this.isworktable3 = true;
        });
        this.pagobj.total = parseInt(ts.d.data.operation2[0].hash.allrs);
      });
    },

    // 获取姓名
    // getpersonid(val) {
    //   this.yearData.hash.pid = val;
    // //   this.yearData.hash.username = val.value;
    // console.log(val,'val')
    // }
  },
};
</script>
<style >

</style>
